<?php

/**
 * photo actions.
 *
 * @package    sfwixet
 * @subpackage photo
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class albumListComponents extends sfComponents
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
	
  public function executeTitle(sfWebRequest $request)
  {
	
  }
  
  public function executeIndex(sfWebRequest $request)
  {
  	$this->showButton = true;
  	$id = $request->getParameter("id");
  	if(is_numeric($id)){
  		try{
  			$this->showButton = false;
  			$album = Doctrine::getTable("Album")->find($id);
  			$user = $album->getOwner();
  			
  			$this->albums = $user->getAllowedAlbums();
  			$this->mainAlbum = $user->getMainAlbum();
  		}catch(Exception $e){
  			//echo json_encode(array("error"=>true,"message"=>$e->getMessage()));
  			$this->showButton = false;
  			$this->albums = $this->getUser()->getGuardUser()->getAlbums();
  			$this->mainAlbum = $this->getUser()->getGuardUser()->getMainAlbum();
  		}
  	}else{
  		$this->albums = $this->getUser()->getGuardUser()->getAlbums();
  		$this->mainAlbum = $this->getUser()->getGuardUser()->getMainAlbum();
  	}

  }
}
